"""
计算指定的年月日是这一年的第几天

Version: 0.1
Author: yuwl
Date：2024-3-19
"""

# 判断给定的年份是不是闰年
def is_leap_year(year):
    return year % 4 == 0 and year % 100 != 0 or year % 400 == 0

def which_day(year, month, date):
    day_of_month = [
        [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
        [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    ][is_leap_year(year)]

    total = 0
    for index in range(month - 1):
        total += day_of_month[index]
    return total + date

print(which_day(2024, 3, 19))